package Gui;

import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;

import GameEngine.GameLogic;
import GameEngine.GameMessage;
import GameEngine.GameSettings;
import GameEngine.Status;

public class TestMain {
	private static final int MINIMAX = 0;
	private static final int ALPHABETA = 1;
	private static final int HEURISTIC = 2;
	private static final int RANDOMMINMAX = 3;
	private static final int RANDOMALPHABETA = 4;

	public static void main(String[] args) {
		GameMessage gameMessage = new GameMessage();
		GameLogic core = null;
		GameGUI mainFrame;
		
		
		try {
			for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
				if ("Nimbus".equals(info.getName())) {
					UIManager.setLookAndFeel(info.getClassName());
					break;
				}
			}
		} catch (Exception e) {
			JOptionPane.showMessageDialog(null, "Failed Charging Nimbus look And Feel"+"\n"+
									"The application will use Default System Look and Feel");
		}

		int numTest = 50;
		int mode = Status.GAME_CVC; //  NON CAMBIARE (MODALITÃ  AI VS AI)
		int algType1 = RANDOMALPHABETA;   // CAMBIARE PRIMO GIOCATORE ARTIFICIALE
		int algType2 = RANDOMALPHABETA; // CAMBIARE SECONDO GIOCATORE ARTIFICIALE
		int iaLevel1 = 2;  // LIVELLO PRIMO GIOCATORE ARTIFICIALE
		int iaLevel2 = 1; //  LIVELLO SECONDO GIOCATORE ARTIFICIALE
		int gameStatus = Status.GAME_ON; // NON CAMBIARE (STATO DEL GIOCO ON)
		boolean isFirstPlayer = false; // NON CAMBIARE (VALORE DI DEFAULT IGNORATO DALLA LOGICA)
		boolean playMode=false;
		GameSettings settings = new GameSettings(mode,isFirstPlayer,algType1,algType2,iaLevel1,iaLevel2,gameStatus);

		
		for(int i=1;i<=numTest;i++){
		
			core = new GameLogic(gameMessage,settings,numTest,i);

			mainFrame = new GameGUI(gameMessage,settings,playMode);

			core.start();

			mainFrame.startGUI();
			
			while(!core.isNewGame()){
				try {
					Thread.sleep(2000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		
		}
		try {
			Thread.sleep(2000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.exit(0);
	}	

}
